#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#define F first
#define S second
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf =0x3f3f3f3f;
void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	int n0=count(s.begin(),s.end(),'0');
	int n1=s.size()-n0;
	int need=(n*(n-1)/2-n0*(n0-1)/2+n1*(n1-1)/2)/2;
	
	vector<vector<int> > f(n1+1,vector<int> (need+1,inf));
	f[0][0]=0;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=min(n1,i);j>=1;j--)
		{	
			for(int k=need;k>=i-1;k--)
			{
				f[j][k]=min(f[j][k],f[j-1][k-i+1]+(s[i-1]=='0'));
			}
		}
	}
	cout<<f[n1][need];
}
int main()
{
	IOS;
	int T=1;
//	cin>>T;

	while(T--)
	{
		solve();
	}

	return 0;
}

